home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / contrib / xbtxbst.doc < prev   
Text File  |  1993-10-09  |  80KB  |  2,778 lines

  1. % /u/sy/beebe/tex/bib/merge/xbtxbst.doc, Mon Oct 11 15:02:15 1993
  2. % Edit by Nelson H. F. Beebe <beebe@plot79.math.utah.edu>
  3. % /u/sy/beebe/tex/bib/merge/xbtxbst.doc, Thu Sep 12 10:19:13 1991
  4. % Edit by Nelson H. F. Beebe <beebe@magna.math.utah.edu>
  5. % /u/sy/beebe/tex/bib/merge/xbtxbst.doc, Wed Oct 17 08:27:24 1990
  6. % Edit by Nelson H.F. Beebe <beebe@sandy.math.utah.edu>
  7. %
  8. % NB: Important convention: comment lines beginning with 2 (or
  9. %     more) percents are to be preserved in the derived style
  10. %     files.   Comment lines beginning with only 1 percent can be
  11. %     discarded (and are, if the derived files are produced with
  12. %     the UNIX Makefile that accompanies this file.)
  13. %
  14. %%%=====================================================================
  15. %%% @BibTeX-style-file{
  16. %%%     author          = "Nelson H. F. Beebe",
  17. %%%     version         = "1.03",
  18. %%%     date            = "11 October 1993",
  19. %%%     time            = "15:03:04 MDT",
  20. %%%     filename        = "xbtxbst.doc",
  21. %%%     address         = "Center for Scientific Computing
  22. %%%                        Department of Mathematics
  23. %%%                        University of Utah
  24. %%%                        Salt Lake City, UT 84112
  25. %%%                        USA",
  26. %%%     telephone       = "+1 801 581 5254",
  27. %%%     FAX             = "+1 801 581 4148",
  28. %%%     checksum        = "22692 2777 11497 80187",
  29. %%%     email           = "beebe@math.utah.edu (Internet)",
  30. %%%     codetable       = "ISO/ASCII",
  31. %%%     keywords        = "BibTeX, style, bibliography",
  32. %%%     supported       = "yes",
  33. %%%     docstring       = "This file is a modification of the standard
  34. %%%                        BibTeX btxbst.doc file, or is a .bst file
  35. %%%                        derived from that modification.  It contains
  36. %%%                        added support for ISBN and ISSN fields, as
  37. %%%                        well as for the PERIODICAL entry.  The UNIX C
  38. %%%                        preprocessor can be used to extract the
  39. %%%                        extensions of the standard styles, as
  40. %%%                        follows:
  41. %%%
  42. %%%                        cpp -P -DPLAIN xbtxbst.doc is-plain.txt
  43. %%%                        cpp -P -DUNSRT xbtxbst.doc is-unsrt.txt
  44. %%%                        cpp -P -DALPHA xbtxbst.doc is-alpha.txt
  45. %%%                        cpp -P -DABBRV xbtxbst.doc is-abbrv.txt
  46. %%%
  47. %%%                        Add -DISBN for ISBN output, -DISSN for
  48. %%%                        ISSN output, -DLCCN for LCCN output, and
  49. %%%                        -DPRICE for price output.
  50. %%%
  51. %%%                        If desired, a sed script can be used to
  52. %%%                        eliminate non-essential comments (this
  53. %%%                        reduces the file size by 2/3); a command
  54. %%%                        filter step like
  55. %%%                                sed -e '/^%$/d' -e '/^%[^%].*$/d'
  56. %%%                        will accomplish that job.
  57. %%%
  58. %%%                        The checksum field above contains a CRC-16
  59. %%%                        checksum as the first value, followed by the
  60. %%%                        equivalent of the standard UNIX wc (word
  61. %%%                        count) utility output of lines, words, and
  62. %%%                        characters.  This is produced by Robert
  63. %%%                        Solovay's checksum utility."
  64. %%%     }
  65. %%% ====================================================================
  66. %%% Revision history (reverse time order):
  67. %%% 1.03 [11-Oct-1993]
  68. %%%     Add support for LCCN (Library of Congress Catalog Number)
  69. %%%     and price fields, and make ISBN, ISSN, LCCN, and price
  70. %%%     selectable by preprocessor conditionals.
  71. %%% 1.02 [12-Sep-1991]
  72. %%%      Merge in Barbara N. Beeton's suggestion for hyphen-less
  73. %%%      line breaks around volume(number):page.
  74. %%% 1.01 [10-Sep-1991]
  75. %%%      Update file comment header and use Solovay checksum program.
  76. %%% 1.00 [17-Oct-1990]
  77. %%%      Original version merging hand-edits of is-xxx.bst files into
  78. %%%      this master file, xbtxbst.doc.
  79.  
  80. % In the following, only essential changes have been applied; the
  81. % documentation immediately below referring to the use of cpp on
  82. % btxbst.doc has not been altered.  See the docstring entry above
  83. % for current information.
  84.  
  85. %% BibTeX `plain' family
  86. %%       version 0.99b for BibTeX versions 0.99a or later, LaTeX version 2.09.
  87. %%       Copyright (C) 1985, all rights reserved.
  88. %%       Copying of this file is authorized only if either
  89. %%       (1) you make absolutely no changes to your copy, including name, or
  90. %%       (2) if you do make changes, you name it something other than
  91. %%       btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst.
  92. %%       This restriction helps ensure that all standard styles are identical.
  93. %%       The file btxbst.doc has the documentation for this style.
  94. %
  95. % Please notify Oren Patashnik (PATASHNIK@SCORE.STANFORD.EDU) of any bugs in
  96. % these standard styles or in this documentation file.
  97. %
  98. % This is file btxbxt.doc; it helps document bibliography styles,
  99. % and is also a template file that you can use to make
  100. % several different style files, if you have access to a C preprocessor.
  101. % For example, the standard styles were made by doing something like
  102. %       cpp -P -DPLAIN btxbst.doc plain.txt
  103. %       cpp -P -DUNSRT btxbst.doc unsrt.txt
  104. %       cpp -P -DALPHA btxbst.doc alpha.txt
  105. %       cpp -P -DABBRV btxbst.doc abbrv.txt
  106. % and then renaming after removing unwanted comments and blank lines.
  107. % If you don't have access,
  108. % you can edit this file by hand to imitate the preprocessor,
  109. % with the following explanation of the C preprocessor constructs used here.
  110. %
  111. % The output of the preprocessor is the same as the input, except that certain
  112. % lines will be excluded (and some blank lines will be added).  The sequence
  113. %       #if VAR
  114. %           lines to be included when VAR is not zero
  115. %       #else
  116. %           lines to be included when VAR is zero
  117. %       #endif
  118. % (with the #-signs appearing in column 1) means that one set or the other of
  119. % the lines are to be included depending on the value of VAR.
  120. % The #else part is optional.  Comments can be added after #else and #endif.
  121. % Variables can be set by
  122. %       #define VAR value
  123. % and one can also use #ifdef VAR to see if VAR has any value, and #ifndef
  124. % to see if it has none.
  125. % Another #if form used in this file is #if !VAR, which includes the lines
  126. % after the #if only if VAR is zero.
  127. %
  128. % Convention: Use all uppercase identifiers for these preprocessor variables
  129. % so you can spot them easily
  130. %
  131. % The command line to the preprocessor should define one of PLAIN, UNSRT, ALPHA
  132. % or ABBRV (though PLAIN will be used by default if none is given),
  133. % and the following lines will set various boolean variables to control the
  134. % various lines that are chosen from the rest of the file.
  135. % Each boolean variable should be set true (1) or false (0) in each style.
  136. % Here are the current variables, and their meanings:
  137. %       LAB_ALPH:       an alphabetic label is used (if false then a numeric
  138. %                           label is used)
  139. %       SORTED:         the entries should be sorted by label (if nonnumeric)
  140. %                           and other info, like authors (if false, then
  141. %                           entries remain in order of occurrence)
  142. %       NAME_FULL:      the authors, editors, etc., get the full names as
  143. %                           given in the bibliography file (if false, the first
  144. %                           names become initials)
  145. %       ATIT_LOWER:     titles of non-"books" (e.g., articles) should be
  146. %                           converted to lower-case, except the first letter or
  147. %                           first letter after a colon
  148. %                           (if false then they appear as in the database)
  149. %       MONTH_FULL:     months are spelled out in full (if false, then
  150. %                           they're abbreviated)
  151. %       JOUR_FULL:      macro journal names are spelled out in full
  152. %                           (if false then they are abbreviated, currently
  153. %                           as they appear in ACM publications)
  154. #ifndef UNSRT
  155. #   ifndef ALPHA
  156. #       ifndef ABBRV
  157. #           define PLAIN 1
  158. #       endif
  159. #   endif
  160. #endif
  161. #ifdef PLAIN
  162. % plain style (sorted numbers)
  163. #   define LAB_ALPH 0
  164. #   define SORTED 1
  165. #   define NAME_FULL 1
  166. #   define ATIT_LOWER 1
  167. #   define MONTH_FULL 1
  168. #   define JOUR_FULL 1
  169. #endif
  170. #ifdef UNSRT
  171. % unsrt style (unsorted numbers)
  172. #   define LAB_ALPH 0
  173. #   define SORTED 0
  174. #   define NAME_FULL 1
  175. #   define ATIT_LOWER 1
  176. #   define MONTH_FULL 1
  177. #   define JOUR_FULL 1
  178. #endif
  179. #ifdef ALPHA
  180. % alpha style (sorted short alphabetics)
  181. #   define LAB_ALPH 1
  182. #   define SORTED 1
  183. #   define NAME_FULL 1
  184. #   define ATIT_LOWER 1
  185. #   define MONTH_FULL 1
  186. #   define JOUR_FULL 1
  187. #endif
  188. #ifdef ABBRV
  189. % abbrv style (sorted numbers, with abbreviations)
  190. #   define LAB_ALPH 0
  191. #   define SORTED 1
  192. #   define NAME_FULL 0
  193. #   define ATIT_LOWER 1
  194. #   define MONTH_FULL 0
  195. #   define JOUR_FULL 0
  196. #endif
  197. %
  198. %   Entry formatting: Similar to that recommended by Mary-Claire van Leunen
  199. %       in "A Handbook for Scholars".  Book-like titles are italicized
  200. %       (emphasized) and non-book titles are converted to sentence
  201. %       capitilization (and not enclosed in quotes).
  202. %       This file outputs a \newblock between major blocks of an entry
  203. %       (the name \newblock is analogous to the names \newline and \newpage)
  204. %       so that the user can obtain an "open" format, which has a line break
  205. %       before each block and lines after the first are indented within blocks,
  206. %       by giving the optional \documentstyle argument `openbib';
  207. %       The default is the "closed" format---blocks runs together.
  208. %
  209. %   Citation alphabetic label format:
  210. %               [Knu73] for single author (or editor or key)
  211. %               [AHU83] (first letters of last names) for multiple authors
  212. %
  213. %   Citation label numberic format:
  214. %               [number]
  215. %
  216. %   Reference list ordering for sorted, alphabetic lables:
  217. %               alphabetical by citation label, then by author(s) or whatever
  218. %               passes for author in the absence of one, then by year,
  219. %               then title
  220. %
  221. %   Reference list ordering for sorted, numeric lables:
  222. %               alphabetical by author(s) or whatever passes
  223. %               for author in the absence of one, then by year, then title
  224. %
  225. %   Reference list ordering for unsorted:
  226. %               by the order cited in the text
  227. %
  228. %   History
  229. %   12/16/84    (HWT)   Original `plain' version, by Howard Trickey.
  230. %   12/23/84    (LL)    Some comments made by Leslie Lamport.
  231. %    2/16/85    (OP)    Changes based on LL's comments, Oren Patashnik.
  232. %    2/17/85    (HWT)   Template file and other standard styles made.
  233. %    3/28/85    (OP)    First release, version 0.98b for BibTeX 0.98f.
  234. %    5/ 9/85    (OP)    Version 0.98c for BibTeX 0.98i:
  235. %                       fixed Theoretical Computer Science macro name;
  236. %                       fixed the format.vol.num.pages function.
  237. %    1/24/88    (OP)    Version 0.99a for BibTeX 0.99a, main changes:
  238. %                       assignment operator (:=) arguments reversed;
  239. %                       the preamble$ function outputs the database PREAMBLE;
  240. %                       entry.max$ and global.max$ (built-in) variables replace
  241. %                       entry.string.max and global.string.max functions;
  242. %                       alphabetizing by year then title, not just title;
  243. %                       many unnecessary ties removed; \it ==> \em;
  244. %                       the `alpha' style uses a superscripted `+' instead of a
  245. %                       `*' for unnamed names in constructing the label;
  246. %                       the `abbrv' style now uses "Mar." and "Sept.";
  247. %                       the functions calc.label and presort now look at just
  248. %                       the fields they're supposed to;
  249. %                       BOOKLET, MASTERSTHESIS, TECHREPORT use nonbook titles;
  250. %                       INBOOK and INCOLLECTION take an optional type (e.g.
  251. %                       type = "Section"), overriding the default "chapter";
  252. %                       BOOK, INBOOK, INCOLLECTION, and PROCEEDINGS now allow
  253. %                       either volume or number, not just volume;
  254. %                       INCOLLECTION now allows an edition and series field;
  255. %                       PROCEEDINGS and INPROCEEDINGS now use the address field
  256. %                       to tell where a conference was held;
  257. %                       INPROCEEDINGS and PROCEEDINGS now allow either volume
  258. %                       or number, and also a series field;
  259. %                       MASTERSTHESIS and PHDTHESIS accept types other than
  260. %                       "Master's thesis" and "PhD thesis";
  261. %                       UNPUBLISHED now outputs, in one block, note then date;
  262. %                       MANUAL now prints out the organization in
  263. %                       the first block if the author field is empty;
  264. %                       MISC can't be empty---it requires some optional field.
  265. %    3/23/88    (OP)    Version 0.99b for BibTeX 0.99c---changed the three
  266. %                       erroneous occurrences of `cite ' to `cite$ '; this
  267. %                       change didn't affect the four standard styles, so the
  268. %                       0.99a versions of those styles are still current.
  269. %
  270. % The ENTRY declaration
  271. %   Like Scribe's (according to pages 231-2 of the April '84 edition),
  272. %   but no fullauthor or editors fields because BibTeX does name handling.
  273. %   The annote field is commented out here because this family doesn't
  274. %   include an annotated bibliography style.  And in addition to the fields
  275. %   listed here, BibTeX has a built-in crossref field, explained later.
  276.  
  277. ENTRY
  278. % Fields:
  279.   { address
  280. %           Usually the address of a publisher or other type of organization.
  281. %           Put information in this field only if it helps the reader find the
  282. %           thing---for example you should omit the address of a major
  283. %           publisher entirely.  For a PROCEEDINGS or an INPROCEEDINGS,
  284. %           however, it's the address of the conference; for those two entry
  285. %           types, include the publisher's or organization's address, if
  286. %           necessary, in the publisher or organization field.
  287. %    annote
  288. %           Long annotation---for annotated bibliographies (begins sentence).
  289.     author
  290. %           Name(s) of author(s), in BibTeX name format.
  291.     booktitle
  292. %           Book title when the thing being referenced isn't the whole book.
  293. %           For book entries, the title field should be used instead.
  294.     chapter
  295. %           Chapter (or section or whatever) number.
  296.     edition
  297. %           Edition of a book---should be an ordinal (e.g., "Second").
  298.     editor
  299. %           Name(s) of editor(s), in BibTeX name format.
  300. %           If there is also an author field, then the editor field should be
  301. %           for the book or collection that the work appears in.
  302.     howpublished
  303. %            How something strange has been published (begins sentence).
  304.     institution
  305. %           Sponsoring institution of a technical report.
  306. #if ISBN
  307.     isbn
  308. %           ISBN book number (a 10-digit number with optional
  309. %           embedded spaces or hyphens, where a `digit' is one of
  310. %           0123456789X).
  311. #endif
  312. #if ISSN
  313.     issn
  314. %           ISSN serial publication number (an 8-digit number with optional
  315. %           embedded spaces or hyphens, where a `digit' is one of
  316. %           0123456789X).
  317. #endif
  318.     journal
  319. %           Journal name (macros are provided for many).
  320.     key
  321. %           Alphabetizing, labeling, and cross-referencing key
  322. %           (needed when an entry has no author or editor).
  323. #if LCCN
  324.     lccn
  325. %           Library of Congress Catalog Number
  326. #endif
  327.     month
  328. %           Month (macros are provided).
  329.     note
  330. %           To help the reader find a reference (begins sentence).
  331.     number
  332. %           Number of a journal or technical report, or of a work in a series.
  333.     organization
  334. %           Organization sponsoring a conference (or publishing a manual); if
  335. %           the editor (or author) is empty, and if the organization produces
  336. %           an awkward label or cross reference, you should put appropriately
  337. %           condensed organization information in the key field as well.
  338.     pages
  339. %           Page number or numbers (use `--' to separate a range, use `+'
  340. %           to indicate pages following that don't form a simple range).
  341. #if PRICE
  342.     price
  343. %           Price in one or more currencies (e.g. US\$29.95, UK\pounds18.50,
  344. %           FF90, DM60)
  345. #endif
  346.     publisher
  347. %           Publisher name.
  348.     school
  349. %           School name (for theses).
  350.     series
  351. %           The name of a series or set of books.
  352. %           An individual book will will also have it's own title.
  353.     title
  354. %           The title of the thing you're referred to.
  355.     type
  356. %           Type of a Techreport (e.g., "Research Note") to be used instead of
  357. %           the default "Technical Report"; or, similarly, the type of a
  358. %           thesis; or of a part of a book.
  359.     volume
  360. %           The volume number of a journal or multivolume work.
  361.     year
  362. %           The year should contain only numerals (technically, it should end
  363. %           with four numerals, after purification; doesn't a begin sentence).
  364.   }
  365. % There are no integer entry variables
  366.   {}
  367. % These string entry variables are used to form the citation label.
  368. % In a storage pinch, sort.label can be easily computed on the fly.
  369. #if LAB_ALPH
  370. #if SORTED
  371.   { label extra.label sort.label }
  372. #else !SORTED
  373. % It doesn't seem like a good idea to use an order-of-citation
  374. % reference list when using alphabetic labels, but when this happens
  375. % we do things a little differently
  376.   { label }
  377. #endif SORTED
  378. #else !LAB_ALPH
  379.   { label }
  380. #endif LAB_ALPH
  381.  
  382. % Each entry function starts by calling output.bibitem, to write the
  383. % \bibitem and its arguments to the .BBL file.  Then the various fields
  384. % are formatted and printed by output or output.check.  Those functions
  385. % handle the writing of separators (commas, periods, \newblock's),
  386. % taking care not to do so when they are passed a null string.
  387. % Finally, fin.entry is called to add the final period and finish the
  388. % entry.
  389. %
  390. % A bibliographic reference is formatted into a number of `blocks':
  391. % in the open format, a block begins on a new line and subsequent
  392. % lines of the block are indented.  A block may contain more than
  393. % one sentence (well, not a grammatical sentence, but something to
  394. % be ended with a sentence ending period).  The entry functions should
  395. % call new.block whenever a block other than the first is about to be
  396. % started.  They should call new.sentence whenever a new sentence is
  397. % to be started.  The output functions will ensure that if two
  398. % new.sentence's occur without any non-null string being output between
  399. % them then there won't be two periods output.  Similarly for two
  400. % successive new.block's.
  401. %
  402. % The output routines don't write their argument immediately.
  403. % Instead, by convention, that argument is saved on the stack to be
  404. % output next time (when we'll know what separator needs to come
  405. % after it).  Meanwhile, the output routine has to pop the pending
  406. % output off the stack, append any needed separator, and write it.
  407. %
  408. % To tell which separator is needed, we maintain an output.state.
  409. % It will be one of these values:
  410. %       before.all              just after the \bibitem
  411. %       mid.sentence            in the middle of a sentence: comma needed
  412. %                                       if more sentence is output
  413. %       after.sentence          just after a sentence: period needed
  414. %       after.block             just after a block (and sentence):
  415. %                                       period and \newblock needed.
  416. % Note: These styles don't use after.sentence
  417. %
  418. % VAR: output.state : INTEGER           -- state variable for output
  419. %
  420. % The output.nonnull function saves its argument (assumed to be nonnull)
  421. % on the stack, and writes the old saved value followed by any needed
  422. % separator.  The ordering of the tests is decreasing frequency of
  423. % occurrence.
  424. %
  425. % output.nonnull(s) ==
  426. %  BEGIN
  427. %       s := argument on stack
  428. %       if output.state = mid.sentence then
  429. %           write$(pop() * ", ")
  430. %                 -- "pop" isn't a function: just use stack top
  431. %       else
  432. %           if output.state = after.block then
  433. %               write$(add.period$(pop()))
  434. %               newline$
  435. %               write$("\newblock ")
  436. %           else
  437. %               if output.state = before.all then
  438. %                   write$(pop())
  439. %               else        -- output.state should be after.sentence
  440. %                   write$(add.period$(pop()) * " ")
  441. %               fi
  442. %           fi
  443. %           output.state := mid.sentence
  444. %       fi
  445. %       push s on stack
  446. %  END
  447. %
  448. % The output function calls output.nonnull if its argument is non-empty;
  449. % its argument may be a missing field (thus, not necessarily a string)
  450. %
  451. % output(s) ==
  452. %  BEGIN
  453. %       if not empty$(s) then output.nonnull(s)
  454. %       fi
  455. %  END
  456. %
  457. % The output.check function is the same as the output function except that, if
  458. % necessary, output.check warns the user that the t field shouldn't be empty
  459. % (this is because it probably won't be a good reference without the field;
  460. % the entry functions try to make the formatting look reasonable even when
  461. % such fields are empty).
  462. %
  463. % output.check(s,t) ==
  464. %  BEGIN
  465. %       if empty$(s) then
  466. %           warning$("empty " * t * " in " * cite$)
  467. %       else output.nonnull(s)
  468. %       fi
  469. %  END
  470. %
  471. % The output.bibitem function writes the \bibitem for the current entry
  472. % (the label should already have been set up), and sets up the separator
  473. % state for the output functions.  And, it leaves a string on the stack
  474. % as per the output convention.
  475. %
  476. % output.bibitem ==
  477. %  BEGIN
  478. %       newline$
  479. %       write$("\bibitem[")     % for alphabetic labels,
  480. %       write$(label)           % these three lines
  481. %       write$("]{")            % are used
  482. %       write$("\bibitem{")             % this line for numeric labels
  483. %       write$(cite$)
  484. %       write$("}")
  485. %       push "" on stack
  486. %       output.state := before.all
  487. %  END
  488. %
  489. % The fin.entry function finishes off an entry by adding a period to the
  490. % string remaining on the stack.  If the state is still before.all
  491. % then nothing was produced for this entry, so the result will look bad,
  492. % but the user deserves it. (We don't omit the whole entry because the
  493. % entry was cited, and a bibitem is needed to define the citation label.)
  494. %
  495. % fin.entry ==
  496. %  BEGIN
  497. %       write$(add.period$(pop()))
  498. %       newline$
  499. %  END
  500. %
  501. % The new.block function prepares for a new block to be output, and
  502. % new.sentence prepares for a new sentence.
  503. %
  504. % new.block ==
  505. %  BEGIN
  506. %       if output.state <> before.all then
  507. %           output.state := after.block
  508. %       fi
  509. %  END
  510. %
  511. % new.sentence ==
  512. %  BEGIN
  513. %       if output.state <> after.block then
  514. %           if output.state <> before.all then
  515. %               output.state :=  after.sentence
  516. %           fi
  517. %       fi
  518. %  END
  519. %
  520.  
  521. INTEGERS { output.state before.all mid.sentence after.sentence after.block }
  522.  
  523. FUNCTION {init.state.consts}
  524. { #0 'before.all :=
  525.   #1 'mid.sentence :=
  526.   #2 'after.sentence :=
  527.   #3 'after.block :=
  528. }
  529.  
  530. % the variables s and t are temporary string holders
  531.  
  532. STRINGS { s t }
  533.  
  534. FUNCTION {output.nonnull}
  535. { 's :=
  536.   output.state mid.sentence =
  537.     { ", " * write$ }
  538.     { output.state after.block =
  539.         { add.period$ write$
  540.           newline$
  541.           "\newblock " write$
  542.         }
  543.         { output.state before.all =
  544.             'write$
  545.             { add.period$ " " * write$ }
  546.           if$
  547.         }
  548.       if$
  549.       mid.sentence 'output.state :=
  550.     }
  551.   if$
  552.   s
  553. }
  554.  
  555. FUNCTION {output}
  556. { duplicate$ empty$
  557.     'pop$
  558.     'output.nonnull
  559.   if$
  560. }
  561.  
  562. FUNCTION {output.check}
  563. { 't :=
  564.   duplicate$ empty$
  565.     { pop$ "empty " t * " in " * cite$ * warning$ }
  566.     'output.nonnull
  567.   if$
  568. }
  569.  
  570. FUNCTION {output.bibitem}
  571. { newline$
  572. #if LAB_ALPH
  573.   "\bibitem[" write$
  574.   label write$
  575.   "]{" write$
  576. #else
  577.   "\bibitem{" write$
  578. #endif LAB_ALPH
  579.   cite$ write$
  580.   "}" write$
  581.   newline$
  582.   ""
  583.   before.all 'output.state :=
  584. }
  585.  
  586. % This function finishes all entries.
  587.  
  588. FUNCTION {fin.entry}
  589. { add.period$
  590.   write$
  591.   newline$
  592. }
  593.  
  594. FUNCTION {new.block}
  595. { output.state before.all =
  596.     'skip$
  597.     { after.block 'output.state := }
  598.   if$
  599. }
  600.  
  601. FUNCTION {new.sentence}
  602. { output.state after.block =
  603.     'skip$
  604.     { output.state before.all =
  605.         'skip$
  606.         { after.sentence 'output.state := }
  607.       if$
  608.     }
  609.   if$
  610. }
  611.  
  612. % These three functions pop one or two (integer) arguments from the stack
  613. % and push a single one, either 0 or 1.
  614. % The 'skip$ in the `and' and `or' functions are used because
  615. % the corresponding if$ would be idempotent
  616.  
  617. FUNCTION {not}
  618. {   { #0 }
  619.     { #1 }
  620.   if$
  621. }
  622.  
  623. FUNCTION {and}
  624. {   'skip$
  625.     { pop$ #0 }
  626.   if$
  627. }
  628.  
  629. FUNCTION {or}
  630. {   { pop$ #1 }
  631.     'skip$
  632.   if$
  633. }
  634.  
  635. % Sometimes we begin a new block only if the block will be big enough.  The
  636. % new.block.checka function issues a new.block if its argument is nonempty;
  637. % new.block.checkb does the same if either of its TWO arguments is nonempty.
  638.  
  639. FUNCTION {new.block.checka}
  640. { empty$
  641.     'skip$
  642.     'new.block
  643.   if$
  644. }
  645.  
  646. FUNCTION {new.block.checkb}
  647. { empty$
  648.   swap$ empty$
  649.   and
  650.     'skip$
  651.     'new.block
  652.   if$
  653. }
  654.  
  655. % The new.sentence.check functions are analogous.
  656.  
  657. FUNCTION {new.sentence.checka}
  658. { empty$
  659.     'skip$
  660.     'new.sentence
  661.   if$
  662. }
  663.  
  664. FUNCTION {new.sentence.checkb}
  665. { empty$
  666.   swap$ empty$
  667.   and
  668.     'skip$
  669.     'new.sentence
  670.   if$
  671. }
  672.  
  673. % Here are some functions for formatting chunks of an entry.
  674. % By convention they either produce a string that can be followed by
  675. % a comma or period (using add.period$, so it is OK to end in a period),
  676. % or they produce the null string.
  677. %
  678. % A useful utility is the field.or.null function, which checks if the
  679. % argument is the result of pushing a `missing' field (one for which no
  680. % assignment was made when the current entry was read in from the database)
  681. % or the result of pushing a string having no non-white-space characters.
  682. % It returns the null string if so, otherwise it returns the field string.
  683. % Its main (but not only) purpose is to guarantee that what's left on the
  684. % stack is a string rather than a missing field.
  685. %
  686. % field.or.null(s) ==
  687. %  BEGIN
  688. %       if empty$(s) then return ""
  689. %       else return s
  690. %  END
  691. %
  692. % Another helper function is emphasize, which returns the argument emphazised,
  693. % if that is non-empty, otherwise it returns the null string.  Italic
  694. % corrections aren't used, so this function should be used when punctation
  695. % will follow the result.
  696. %
  697. % emphasize(s) ==
  698. %  BEGIN
  699. %       if empty$(s) then return ""
  700. %       else return "{\em " * s * "}"
  701. %
  702. % The format.names function formats the argument (which should be in
  703. % BibTeX name format) into "First Von Last, Junior", separated by commas
  704. % and with an "and" before the last (but ending with "et~al." if the last
  705. % of multiple authors is "others").  This function's argument should always
  706. % contain at least one name.
  707. %
  708. % VAR: nameptr, namesleft, numnames: INTEGER
  709. % pseudoVAR: nameresult: STRING         (it's what's accumulated on the stack)
  710. %
  711. % format.names(s) ==
  712. %  BEGIN
  713. %       nameptr := 1
  714. %       numnames := num.names$(s)
  715. %       namesleft := numnames
  716. %       while namesleft > 0
  717. %         do
  718. %                               % for full names:
  719. %           t := format.name$(s, nameptr, "{ff~}{vv~}{ll}{, jj}")
  720. %                               % for abbreviated first names:
  721. %           t := format.name$(s, nameptr, "{f.~}{vv~}{ll}{, jj}")
  722. %           if nameptr > 1 then
  723. %               if namesleft > 1 then nameresult := nameresult * ", " * t
  724. %               else if numnames > 2
  725. %                      then nameresult := nameresult * ","
  726. %                    fi
  727. %                    if t = "others"
  728. %                      then nameresult := nameresult * " et~al."
  729. %                      else nameresult := nameresult * " and " * t
  730. %                    fi
  731. %               fi
  732. %           else nameresult := t
  733. %           fi
  734. %           nameptr := nameptr + 1
  735. %           namesleft := namesleft - 1
  736. %         od
  737. %       return nameresult
  738. %  END
  739. %
  740. % The format.authors function returns the result of format.names(author)
  741. % if the author is present, or else it returns the null string
  742. %
  743. % format.authors ==
  744. %  BEGIN
  745. %       if empty$(author) then return ""
  746. %       else return format.names(author)
  747. %       fi
  748. %  END
  749. %
  750. % Format.editors is like format.authors, but it uses the editor field,
  751. % and appends ", editor" or ", editors"
  752. %
  753. % format.editors ==
  754. %  BEGIN
  755. %       if empty$(editor) then return ""
  756. %       else
  757. %           if num.names$(editor) > 1 then
  758. %               return format.names(editor) * ", editors"
  759. %           else
  760. %               return format.names(editor) * ", editor"
  761. %           fi
  762. %       fi
  763. %  END
  764. %
  765. % Other formatting functions are similar, so no "comment version" will be
  766. % given for them.
  767. %
  768. % The `pop$' in this function gets rid of the duplicate `empty' value and
  769. % the `skip$' returns the duplicate field value
  770.  
  771. FUNCTION {field.or.null}
  772. { duplicate$ empty$
  773.     { pop$ "" }
  774.     'skip$
  775.   if$
  776. }
  777.  
  778. FUNCTION {emphasize}
  779. { duplicate$ empty$
  780.     { pop$ "" }
  781.     { "{\em " swap$ * "}" * }
  782.   if$
  783. }
  784.  
  785. INTEGERS { nameptr namesleft numnames }
  786.  
  787. FUNCTION {format.names}
  788. { 's :=
  789.   #1 'nameptr :=
  790.   s num.names$ 'numnames :=
  791.   numnames 'namesleft :=
  792.     { namesleft #0 > }
  793. #if NAME_FULL
  794.     { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't :=
  795. #else
  796.     { s nameptr "{f.~}{vv~}{ll}{, jj}" format.name$ 't :=
  797. #endif NAME_FULL
  798.       nameptr #1 >
  799.         { namesleft #1 >
  800.             { ", " * t * }
  801.             { numnames #2 >
  802.                 { "," * }
  803.                 'skip$
  804.               if$
  805.               t "others" =
  806.                 { " et~al." * }
  807.                 { " and " * t * }
  808.               if$
  809.             }
  810.           if$
  811.         }
  812.         't
  813.       if$
  814.       nameptr #1 + 'nameptr :=
  815.       namesleft #1 - 'namesleft :=
  816.     }
  817.   while$
  818. }
  819.  
  820. FUNCTION {format.authors}
  821. { author empty$
  822.     { "" }
  823.     { author format.names }
  824.   if$
  825. }
  826.  
  827. FUNCTION {format.editors}
  828. { editor empty$
  829.     { "" }
  830.     { editor format.names
  831.       editor num.names$ #1 >
  832.         { ", editors" * }
  833.         { ", editor" * }
  834.       if$
  835.     }
  836.   if$
  837. }
  838.  
  839. #if ISBN
  840. FUNCTION {format.isbn}
  841. { isbn empty$
  842.     { "" }
  843.     { new.block "ISBN " isbn * }
  844.   if$
  845. }
  846. #endif
  847.  
  848. #if ISSN
  849. FUNCTION {format.issn}
  850. { issn empty$
  851.     { "" }
  852.     { new.block "ISSN " issn * }
  853.   if$
  854. }
  855. #endif
  856.  
  857. #if LCCN
  858. FUNCTION {format.lccn}
  859. { lccn empty$
  860.     { "" }
  861.     { new.block "LCCN " lccn * }
  862.   if$
  863. }
  864. #endif
  865.  
  866. #if PRICE
  867. FUNCTION {format.price}
  868. { price empty$
  869.     { "" }
  870.     { new.block " " price * }
  871.   if$
  872. }
  873. #endif
  874.  
  875.  
  876.  
  877. % The format.title function is used for non-book-like titles.
  878. % For most styles we convert to lowercase (except for the very first letter,
  879. % and except for the first one after a colon (followed by whitespace)),
  880. % and hope the user has brace-surrounded words that need to stay capitilized;
  881. % for some styles, however, we leave it as it is in the database.
  882.  
  883. FUNCTION {format.title}
  884. { title empty$
  885.     { "" }
  886. #if ATIT_LOWER
  887.     { title "t" change.case$ }
  888. #else
  889.     'title
  890. #endif ATIT_LOWER
  891.   if$
  892. }
  893.  
  894. % By default, BibTeX sets the global integer variable global.max$ to the BibTeX
  895. % constant glob_str_size, the maximum length of a global string variable.
  896. % Analogously, BibTeX sets the global integer variable entry.max$ to
  897. % ent_str_size, the maximum length of an entry string variable.
  898. % The style designer may change these if necessary (but this is unlikely)
  899.  
  900. % The n.dashify function makes each single `-' in a string a double `--'
  901. % if it's not already
  902. %
  903. % pseudoVAR: pageresult: STRING         (it's what's accumulated on the stack)
  904. %
  905. % n.dashify(s) ==
  906. %  BEGIN
  907. %       t := s
  908. %       pageresult := ""
  909. %       while (not empty$(t))
  910. %         do
  911. %           if (first character of t = "-")
  912. %             then
  913. %               if (next character isn't)
  914. %                 then
  915. %                   pageresult := pageresult * "--"
  916. %                   t := t with the "-" removed
  917. %                 else
  918. %                   while (first character of t = "-")
  919. %                     do
  920. %                       pageresult := pageresult * "-"
  921. %                       t := t with the "-" removed
  922. %                     od
  923. %               fi
  924. %             else
  925. %               pageresult := pageresult * the first character
  926. %               t := t with the first character removed
  927. %           fi
  928. %         od
  929. %       return pageresult
  930. %  END
  931.  
  932. FUNCTION {n.dashify}
  933. { 't :=
  934.   ""
  935.     { t empty$ not }
  936.     { t #1 #1 substring$ "-" =
  937.         { t #1 #2 substring$ "--" = not
  938.             { "--" *
  939.               t #2 global.max$ substring$ 't :=
  940.             }
  941.             {   { t #1 #1 substring$ "-" = }
  942.                 { "-" *
  943.                   t #2 global.max$ substring$ 't :=
  944.                 }
  945.               while$
  946.             }
  947.           if$
  948.         }
  949.         { t #1 #1 substring$ *
  950.           t #2 global.max$ substring$ 't :=
  951.         }
  952.       if$
  953.     }
  954.   while$
  955. }
  956.  
  957. % The format.date function is for the month and year, but we give a warning if
  958. % there's an empty year but the month is there, and we return the empty string
  959. % if they're both empty.
  960.  
  961. FUNCTION {format.date}
  962. { year empty$
  963.     { month empty$
  964.         { "" }
  965.         { "there's a month but no year in " cite$ * warning$
  966.           month
  967.         }
  968.       if$
  969.     }
  970.     { month empty$
  971.         'year
  972.         { month " " * year * }
  973.       if$
  974.     }
  975.   if$
  976. }
  977.  
  978. % The format.btitle is for formatting the title field when it is a book-like
  979. % entry---the style used here keeps it in uppers-and-lowers and emphasizes it.
  980.  
  981. FUNCTION {format.btitle}
  982. { title emphasize
  983. }
  984.  
  985. % For several functions we'll need to connect two strings with a
  986. % tie (~) if the second one isn't very long (fewer than 3 characters).
  987. % The tie.or.space.connect function does that.  It concatenates the two
  988. % strings on top of the stack, along with either a tie or space between
  989. % them, and puts this concatenation back onto the stack:
  990. %
  991. % tie.or.space.connect(str1,str2) ==
  992. %    BEGIN
  993. %       if text.length$(str2) < 3
  994. %         then return the concatenation of str1, "~", and str2
  995. %         else return the concatenation of str1, " ", and str2
  996. %    END
  997.  
  998. FUNCTION {tie.or.space.connect}
  999. { duplicate$ text.length$ #3 <
  1000.     { "~" }
  1001.     { " " }
  1002.   if$
  1003.   swap$ * *
  1004. }
  1005.  
  1006. % The either.or.check function complains if both fields or an either-or pair
  1007. % are nonempty.
  1008. %
  1009. % either.or.check(t,s) ==
  1010. %  BEGIN
  1011. %       if empty$(s) then
  1012. %           warning$(can't use both " * t * " fields in " * cite$)
  1013. %       fi
  1014. %  END
  1015.  
  1016. FUNCTION {either.or.check}
  1017. { empty$
  1018.     'pop$
  1019.     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  1020.   if$
  1021. }
  1022.  
  1023. % The format.bvolume function is for formatting the volume and perhaps
  1024. % series name of a multivolume work.  If both a volume and a series field
  1025. % are there, we assume the series field is the title of the whole multivolume
  1026. % work (the title field should be the title of the thing being referred to),
  1027. % and we add an "of <series>".  This function is called in mid-sentence.
  1028.  
  1029. FUNCTION {format.bvolume}
  1030. { volume empty$
  1031.     { "" }
  1032.     { "volume" volume tie.or.space.connect
  1033.       series empty$
  1034.         'skip$
  1035.         { " of " * series emphasize * }
  1036.       if$
  1037.       "volume and number" number either.or.check
  1038.     }
  1039.   if$
  1040. }
  1041.  
  1042. % The format.number.series function is for formatting the series name
  1043. % and perhaps number of a work in a series.  This function is similar to
  1044. % format.bvolume, although for this one the series must exist (and the
  1045. % volume must not exist).  If the number field is empty we output either
  1046. % the series field unchanged if it exists or else the null string.
  1047. % If both the number and series fields are there we assume the series field
  1048. % gives the name of the whole series (the title field should be the title
  1049. % of the work being one referred to), and we add an "in <series>".
  1050. % We capitilize Number when this function is used at the beginning of a block.
  1051.  
  1052. FUNCTION {format.number.series}
  1053. { volume empty$
  1054.     { number empty$
  1055.         { series field.or.null }
  1056.         { output.state mid.sentence =
  1057.             { "number" }
  1058.             { "Number" }
  1059.           if$
  1060.           number tie.or.space.connect
  1061.           series empty$
  1062.             { "there's a number but no series in " cite$ * warning$ }
  1063.             { " in " * series * }
  1064.           if$
  1065.         }
  1066.       if$
  1067.     }
  1068.     { "" }
  1069.   if$
  1070. }
  1071.  
  1072. % The format.edition function appends " edition" to the edition, if present.
  1073. % We lowercase the edition (it should be something like "Third"), because
  1074. % this doesn't start a sentence.
  1075.  
  1076. FUNCTION {format.edition}
  1077. { edition empty$
  1078.     { "" }
  1079.     { output.state mid.sentence =
  1080.         { edition "l" change.case$ " edition" * }
  1081.         { edition "t" change.case$ " edition" * }
  1082.       if$
  1083.     }
  1084.   if$
  1085. }
  1086.  
  1087. % The format.pages function is used for formatting a page range in a book
  1088. % (and in rare circumstances, an article).
  1089. %
  1090. % The multi.page.check function examines the page field for a "-" or "," or "+"
  1091. % so that format.pages can use "page" instead of "pages" if none exists.
  1092. % Note: global.max$ here means "take the rest of the string"
  1093. %
  1094. % VAR: multiresult: INTEGER     (actually, a boolean)
  1095. %
  1096. % multi.page.check(s) ==
  1097. %  BEGIN
  1098. %       t := s
  1099. %       multiresult := false
  1100. %       while ((not multiresult) and (not empty$(t)))
  1101. %         do
  1102. %           if (first character of t = "-" or "," or "+")
  1103. %             then multiresult := true
  1104. %             else t := t with the first character removed
  1105. %           fi
  1106. %         od
  1107. %       return multiresult
  1108. %  END
  1109.  
  1110. INTEGERS { multiresult }
  1111.  
  1112. FUNCTION {multi.page.check}
  1113. { 't :=
  1114.   #0 'multiresult :=
  1115.     { multiresult not
  1116.       t empty$ not
  1117.       and
  1118.     }
  1119.     { t #1 #1 substring$
  1120.       duplicate$ "-" =
  1121.       swap$ duplicate$ "," =
  1122.       swap$ "+" =
  1123.       or or
  1124.         { #1 'multiresult := }
  1125.         { t #2 global.max$ substring$ 't := }
  1126.       if$
  1127.     }
  1128.   while$
  1129.   multiresult
  1130. }
  1131.  
  1132. % This function doesn't begin a sentence so "pages" isn't capitalized.
  1133. % Other functions that use this should keep that in mind.
  1134.  
  1135. FUNCTION {format.pages}
  1136. { pages empty$
  1137.     { "" }
  1138.     { pages multi.page.check
  1139.         { "pages" pages n.dashify tie.or.space.connect }
  1140.         { "page" pages tie.or.space.connect }
  1141.       if$
  1142.     }
  1143.   if$
  1144. }
  1145.  
  1146. % The format.vol.num.pages function is for the volume, number, and page range
  1147. % of a journal article.  We use the format:  vol(number):pages, with some
  1148. % variations for empty fields.  This doesn't begin a sentence.
  1149.  
  1150. FUNCTION {format.vol.num.pages}
  1151. { volume field.or.null
  1152.   number empty$
  1153.     'skip$
  1154.     { "\penalty0 (" number * ")" * *
  1155.       volume empty$
  1156.         { "there's a number but no volume in " cite$ * warning$ }
  1157.         'skip$
  1158.       if$
  1159.     }
  1160.   if$
  1161.   pages empty$
  1162.     'skip$
  1163.     { duplicate$ empty$
  1164.         { pop$ format.pages }
  1165.         { ":\penalty0 " * pages n.dashify * }
  1166.       if$
  1167.     }
  1168.   if$
  1169. }
  1170.  
  1171.  
  1172. % The format.chapter.pages, if the chapter is present, puts whatever is in the
  1173. % type field (or else "chapter" if type is empty) in front of a chapter number.
  1174. % It then appends the pages, if present.  This doesn't begin a sentence.
  1175.  
  1176. FUNCTION {format.chapter.pages}
  1177. { chapter empty$
  1178.     'format.pages
  1179.     { type empty$
  1180.         { "chapter" }
  1181.         { type "l" change.case$ }
  1182.       if$
  1183.       chapter tie.or.space.connect
  1184.       pages empty$
  1185.         'skip$
  1186.         { ", " * format.pages * }
  1187.       if$
  1188.     }
  1189.   if$
  1190. }
  1191.  
  1192. % The format.in.ed.booktitle function is used for starting out a sentence
  1193. % that begins "In <booktitle>", putting an editor before the title if one
  1194. % exists.
  1195.  
  1196. FUNCTION {format.in.ed.booktitle}
  1197. { booktitle empty$
  1198.     { "" }
  1199.     { editor empty$
  1200.         { "In " booktitle emphasize * }
  1201.         { "In " format.editors * ", " * booktitle emphasize * }
  1202.       if$
  1203.     }
  1204.   if$
  1205. }
  1206.  
  1207. % The function empty.misc.check complains if all six fields are empty, and
  1208. % if there's been no sorting or alphabetic-label complaint.
  1209.  
  1210. FUNCTION {empty.misc.check}
  1211. { author empty$ title empty$ howpublished empty$
  1212.   month empty$ year empty$ note empty$
  1213.   and and and and and
  1214. #if SORTED
  1215.   key empty$ not and
  1216. #else !SORTED
  1217. #if LAB_ALPH
  1218.   key empty$ not and
  1219. #endif LAB_ALPH
  1220. #endif SORTED
  1221.     { "all relevant fields are empty in " cite$ * warning$ }
  1222.     'skip$
  1223.   if$
  1224. }
  1225.  
  1226. % The function format.thesis.type returns either the (case-changed) type field,
  1227. % if it is defined, or else the default string already on the stack
  1228. % (like "Master's thesis" or "PhD thesis").
  1229.  
  1230. FUNCTION {format.thesis.type}
  1231. { type empty$
  1232.     'skip$
  1233.     { pop$
  1234.       type "t" change.case$
  1235.     }
  1236.   if$
  1237. }
  1238.  
  1239. % The function format.tr.number makes a string starting with "Technical Report"
  1240. % (or type, if that field is defined), followed by the number if there is one;
  1241. % it returns the starting part (with a case change) even if there is no number.
  1242. % This is used at the beginning of a sentence.
  1243.  
  1244. FUNCTION {format.tr.number}
  1245. { type empty$
  1246.     { "Technical Report" }
  1247.     'type
  1248.   if$
  1249.   number empty$
  1250.     { "t" change.case$ }
  1251.     { number tie.or.space.connect }
  1252.   if$
  1253. }
  1254.  
  1255. % Now come the cross-referencing functions (these are invoked because
  1256. % one entry in the database file(s) cross-references another, by giving
  1257. % the other entry's database key in a `crossref' field).  This feature
  1258. % allows one or more titled things that are part of a larger titled
  1259. % thing to cross-reference the larger thing.  These styles allow for
  1260. % five posibilities: (1) an ARTICLE may cross-reference an ARTICLE;
  1261. % (2) a BOOK, (3) INBOOK, or (4) INCOLLECTION may cross-reference a BOOK;
  1262. % or (5) an INPROCEEDINGS may cross-reference a PROCEEDINGS.
  1263. % Each of these is explained in more detail later.
  1264. %
  1265. % An ARTICLE entry type may cross reference another ARTICLE (this is
  1266. % intended for when an entire journal is devoted to a single topic---
  1267. % but since there is no JOURNAL entry type, the journal, too, should be
  1268. % classified as an ARTICLE but without the author and title fields).
  1269. % This will result in two warning messages for the journal's entry
  1270. % if it's included in the reference list, but such is life.
  1271. %
  1272. % format.article.crossref ==
  1273. %  BEGIN
  1274. %       if empty$(key) then
  1275. %           if empty$(journal) then
  1276. %               warning$("need key or journal for " * cite$ *
  1277. %                                               " to crossref " * crossref)
  1278. %               return(" \cite{" * crossref * "}")
  1279. %           else
  1280. %               return("In " * emphasize.correct (journal) *
  1281. %                                               " \cite{" * crossref * "}")
  1282. %               fi
  1283. %       else
  1284. %           return("In " * key * " \cite{" * crossref * "}")
  1285. %       fi
  1286. %  END
  1287. %
  1288. % The other cross-referencing functions are similar, so no "comment version"
  1289. % will be given for them.
  1290.  
  1291. FUNCTION {format.article.crossref}
  1292. { key empty$
  1293.     { journal empty$
  1294.         { "need key or journal for " cite$ * " to crossref " * crossref *
  1295.           warning$
  1296.           ""
  1297.         }
  1298.         { "In {\em " journal * "\/}" * }
  1299.       if$
  1300.     }
  1301.     { "In " key * }
  1302.   if$
  1303.   " \cite{" * crossref * "}" *
  1304. }
  1305.  
  1306. % We use just the last names of editors for a cross reference: either
  1307. % "editor", or "editor1 and editor2", or "editor1 et~al." depending on
  1308. % whether there are one, or two, or more than two editors.
  1309.  
  1310. FUNCTION {format.crossref.editor}
  1311. { editor #1 "{vv~}{ll}" format.name$
  1312.   editor num.names$ duplicate$
  1313.   #2 >
  1314.     { pop$ " et~al." * }
  1315.     { #2 <
  1316.         'skip$
  1317.         { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  1318.             { " et~al." * }
  1319.             { " and " * editor #2 "{vv~}{ll}" format.name$ * }
  1320.           if$
  1321.         }
  1322.       if$
  1323.     }
  1324.   if$
  1325. }
  1326.  
  1327. % A BOOK (or INBOOK) entry type (assumed to be for a single volume in a
  1328. % multivolume work) may cross reference another BOOK (the entire multivolume).
  1329. % Usually there will be an editor, in which case we use that to construct the
  1330. % cross reference; otherwise we use a nonempty key field or else the series
  1331. % field (since the series gives the title of the multivolume work).
  1332.  
  1333. FUNCTION {format.book.crossref}
  1334. { volume empty$
  1335.     { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
  1336.       "In "
  1337.     }
  1338.     { "Volume" volume tie.or.space.connect
  1339.       " of " *
  1340.     }
  1341.   if$
  1342.   editor empty$
  1343.   editor field.or.null author field.or.null =
  1344.   or
  1345.     { key empty$
  1346.         { series empty$
  1347.             { "need editor, key, or series for " cite$ * " to crossref " *
  1348.               crossref * warning$
  1349.               "" *
  1350.             }
  1351.             { "{\em " * series * "\/}" * }
  1352.           if$
  1353.         }
  1354.         { key * }
  1355.       if$
  1356.     }
  1357.     { format.crossref.editor * }
  1358.   if$
  1359.   " \cite{" * crossref * "}" *
  1360. }
  1361.  
  1362. % An INCOLLECTION entry type may cross reference a BOOK (assumed to be the
  1363. % collection), or an INPROCEEDINGS may cross reference a PROCEEDINGS.
  1364. % Often there will be an editor, in which case we use that to construct
  1365. % the cross reference; otherwise we use a nonempty key field or else
  1366. % the booktitle field (which gives the cross-referenced work's title).
  1367.  
  1368. FUNCTION {format.incoll.inproc.crossref}
  1369. { editor empty$
  1370.   editor field.or.null author field.or.null =
  1371.   or
  1372.     { key empty$
  1373.         { booktitle empty$
  1374.             { "need editor, key, or booktitle for " cite$ * " to crossref " *
  1375.               crossref * warning$
  1376.               ""
  1377.             }
  1378.             { "In {\em " booktitle * "\/}" * }
  1379.           if$
  1380.         }
  1381.         { "In " key * }
  1382.       if$
  1383.     }
  1384.     { "In " format.crossref.editor * }
  1385.   if$
  1386.   " \cite{" * crossref * "}" *
  1387. }
  1388.  
  1389. % Now we define the type functions for all entry types that may appear
  1390. % in the .BIB file---e.g., functions like `article' and `book'.  These
  1391. % are the routines that actually generate the .BBL-file output for
  1392. % the entry.  These must all precede the READ command.  In addition, the
  1393. % style designer should have a function `default.type' for unknown types.
  1394. % Note: The fields (within each list) are listed in order of appearance,
  1395. % except as described for an `inbook' or a `proceedings'.
  1396. %
  1397. % The article function is for an article in a journal.  An article may
  1398. % CROSSREF another article.
  1399. %       Required fields: author, title, journal, year
  1400. %       Optional fields: volume, number, pages, month, note
  1401. %
  1402. % article ==
  1403. %  BEGIN
  1404. %       output.bibitem
  1405. %       output.check(format.authors,"author")
  1406. %       new.block
  1407. %       output.check(format.title,"title")
  1408. %       new.block
  1409. %       if missing$(crossref) then
  1410. %           output.check(emphasize(journal),"journal")
  1411. %           output(format.vol.num.pages)
  1412. %           output.check(format.date,"year")
  1413. %       else
  1414. %           output.nonnull(format.article.crossref)
  1415. %           output(format.pages)
  1416. %       fi
  1417. %       new.block
  1418. %       output(note)
  1419. %       fin.entry
  1420. %  END
  1421. %
  1422. % The book function is for a whole book.  A book may CROSSREF another book.
  1423. %       Required fields: author or editor, title, publisher, year
  1424. %       Optional fields: volume or number, series, address, edition, month,
  1425. %                       note
  1426. %
  1427. % book ==
  1428. %  BEGIN
  1429. %       if empty$(author) then output.check(format.editors,"author and editor")
  1430. %       else    output.check(format.authors,"author")
  1431. %               if missing$(crossref) then
  1432. %                   either.or.check("author and editor",editor)
  1433. %               fi
  1434. %       fi
  1435. %       new.block
  1436. %       output.check(format.btitle,"title")
  1437. %       if missing$(crossref) then
  1438. %           output(format.bvolume)
  1439. %           new.block
  1440. %           output(format.number.series)
  1441. %           new.sentence
  1442. %           output.check(publisher,"publisher")
  1443. %           output(address)
  1444. %       else
  1445. %           new.block
  1446. %           output.nonnull(format.book.crossref)
  1447. %       fi
  1448. %       output(format.edition)
  1449. %       output.check(format.date,"year")
  1450. %       new.block
  1451. %       output(note)
  1452. %       fin.entry
  1453. %  END
  1454. %
  1455. % The other entry functions are all quite similar, so no "comment version"
  1456. % will be given for them.
  1457.  
  1458. FUNCTION {article}
  1459. { output.bibitem
  1460.   format.authors "author" output.check
  1461.   new.block
  1462.   format.title "title" output.check
  1463.   new.block
  1464.   crossref missing$
  1465.     { journal emphasize "journal" output.check
  1466.       format.vol.num.pages output
  1467.       format.date "year" output.check
  1468.     }
  1469.     { format.article.crossref output.nonnull
  1470.       format.pages output
  1471.     }
  1472.   if$
  1473.   new.block
  1474.   note output
  1475.   fin.entry
  1476. }
  1477.  
  1478. FUNCTION {book}
  1479. { output.bibitem
  1480.   author empty$
  1481.     { format.editors "author and editor" output.check }
  1482.     { format.authors output.nonnull
  1483.       crossref missing$
  1484.         { "author and editor" editor either.or.check }
  1485.         'skip$
  1486.       if$
  1487.     }
  1488.   if$
  1489.   new.block
  1490.   format.btitle "title" output.check
  1491.   crossref missing$
  1492.     { format.bvolume output
  1493.       new.block
  1494.       format.number.series output
  1495.       new.sentence
  1496.       publisher "publisher" output.check
  1497.       address output
  1498.     }
  1499.     { new.block
  1500.       format.book.crossref output.nonnull
  1501.     }
  1502.   if$
  1503.   format.edition output
  1504.   format.date "year" output.check
  1505. #if ISBN
  1506.   format.isbn output
  1507. #endif
  1508. #if LCCN
  1509.   format.lccn output
  1510. #endif
  1511. #if PRICE
  1512.   format.price output
  1513. #endif
  1514.   new.block
  1515.   note output
  1516.   fin.entry
  1517. }
  1518.  
  1519. % A booklet is a bound thing without a publisher or sponsoring institution.
  1520. %       Required: title
  1521. %       Optional: author, howpublished, address, month, year, note
  1522.  
  1523. FUNCTION {booklet}
  1524. { output.bibitem
  1525.   format.authors output
  1526.   new.block
  1527.   format.title "title" output.check
  1528.   howpublished address new.block.checkb
  1529.   howpublished output
  1530.   address output
  1531.   format.date output
  1532. #if ISBN
  1533.   format.isbn output
  1534. #endif
  1535. #if LCCN
  1536.   format.lccn output
  1537. #endif
  1538. #if PRICE
  1539.   format.price output
  1540. #endif
  1541.   new.block
  1542.   note output
  1543.   fin.entry
  1544. }
  1545.  
  1546. % For the conference entry type, see inproceedings.
  1547.  
  1548. % An inbook is a piece of a book: either a chapter and/or a page range.
  1549. % It may CROSSREF a book.  If there's no volume field, the type field
  1550. % will come before number and series.
  1551. %       Required: author or editor, title, chapter and/or pages, publisher,year
  1552. %       Optional: volume or number, series, type, address, edition, month, note
  1553.  
  1554. FUNCTION {inbook}
  1555. { output.bibitem
  1556.   author empty$
  1557.     { format.editors "author and editor" output.check }
  1558.     { format.authors output.nonnull
  1559.       crossref missing$
  1560.         { "author and editor" editor either.or.check }
  1561.         'skip$
  1562.       if$
  1563.     }
  1564.   if$
  1565.   new.block
  1566.   format.btitle "title" output.check
  1567.   crossref missing$
  1568.     { format.bvolume output
  1569.       format.chapter.pages "chapter and pages" output.check
  1570.       new.block
  1571.       format.number.series output
  1572.       new.sentence
  1573.       publisher "publisher" output.check
  1574.       address output
  1575.     }
  1576.     { format.chapter.pages "chapter and pages" output.check
  1577.       new.block
  1578.       format.book.crossref output.nonnull
  1579.     }
  1580.   if$
  1581.   format.edition output
  1582.   format.date "year" output.check
  1583. #if ISBN
  1584.   format.isbn output
  1585. #endif
  1586. #if LCCN
  1587.   format.lccn output
  1588. #endif
  1589. #if PRICE
  1590.   format.price output
  1591. #endif
  1592.   new.block
  1593.   note output
  1594.   fin.entry
  1595. }
  1596.  
  1597. % An incollection is like inbook, but where there is a separate title
  1598. % for the referenced thing (and perhaps an editor for the whole).
  1599. % An incollection may CROSSREF a book.
  1600. %       Required: author, title, booktitle, publisher, year
  1601. %       Optional: editor, volume or number, series, type, chapter, pages,
  1602. %                       address, edition, month, note
  1603.  
  1604. FUNCTION {incollection}
  1605. { output.bibitem
  1606.   format.authors "author" output.check
  1607.   new.block
  1608.   format.title "title" output.check
  1609.   new.block
  1610.   crossref missing$
  1611.     { format.in.ed.booktitle "booktitle" output.check
  1612.       format.bvolume output
  1613.       format.number.series output
  1614.       format.chapter.pages output
  1615.       new.sentence
  1616.       publisher "publisher" output.check
  1617.       address output
  1618.       format.edition output
  1619.       format.date "year" output.check
  1620.     }
  1621.     { format.incoll.inproc.crossref output.nonnull
  1622.       format.chapter.pages output
  1623.     }
  1624.   if$
  1625. #if ISBN
  1626.   format.isbn output
  1627. #endif
  1628. #if LCCN
  1629.   format.lccn output
  1630. #endif
  1631. #if PRICE
  1632.   format.price output
  1633. #endif
  1634.   new.block
  1635.   note output
  1636.   fin.entry
  1637. }
  1638.  
  1639. % An inproceedings is an article in a conference proceedings, and it may
  1640. % CROSSREF a proceedings.  If there's no address field, the month (& year)
  1641. % will appear just before note.
  1642. %       Required: author, title, booktitle, year
  1643. %       Optional: editor, volume or number, series, pages, address, month,
  1644. %                       organization, publisher, note
  1645.  
  1646. FUNCTION {inproceedings}
  1647. { output.bibitem
  1648.   format.authors "author" output.check
  1649.   new.block
  1650.   format.title "title" output.check
  1651.   new.block
  1652.   crossref missing$
  1653.     { format.in.ed.booktitle "booktitle" output.check
  1654.       format.bvolume output
  1655.       format.number.series output
  1656.       format.pages output
  1657.       address empty$
  1658.         { organization publisher new.sentence.checkb
  1659.           organization output
  1660.           publisher output
  1661.           format.date "year" output.check
  1662.         }
  1663.         { address output.nonnull
  1664.           format.date "year" output.check
  1665.           new.sentence
  1666.           organization output
  1667.           publisher output
  1668.         }
  1669.       if$
  1670.     }
  1671.     { format.incoll.inproc.crossref output.nonnull
  1672.       format.pages output
  1673.     }
  1674.   if$
  1675. #if ISBN
  1676.   format.isbn output
  1677. #endif
  1678. #if LCCN
  1679.   format.lccn output
  1680. #endif
  1681. #if PRICE
  1682.   format.price output
  1683. #endif
  1684.   new.block
  1685.   note output
  1686.   fin.entry
  1687. }
  1688.  
  1689. % The conference function is included for Scribe compatibility.
  1690.  
  1691. FUNCTION {conference} { inproceedings }
  1692.  
  1693. % A manual is technical documentation.
  1694. %       Required: title
  1695. %       Optional: author, organization, address, edition, month, year, note
  1696.  
  1697. FUNCTION {manual}
  1698. { output.bibitem
  1699.   author empty$
  1700.     { organization empty$
  1701.         'skip$
  1702.         { organization output.nonnull
  1703.           address output
  1704.         }
  1705.       if$
  1706.     }
  1707.     { format.authors output.nonnull }
  1708.   if$
  1709.   new.block
  1710.   format.btitle "title" output.check
  1711.   author empty$
  1712.     { organization empty$
  1713.         { address new.block.checka
  1714.           address output
  1715.         }
  1716.         'skip$
  1717.       if$
  1718.     }
  1719.     { organization address new.block.checkb
  1720.       organization output
  1721.       address output
  1722.     }
  1723.   if$
  1724.   format.edition output
  1725.   format.date output
  1726. #if PRICE
  1727.   format.price output
  1728. #endif
  1729.   new.block
  1730.   note output
  1731.   fin.entry
  1732. }
  1733.  
  1734. % A mastersthesis is a Master's thesis.
  1735. %       Required: author, title, school, year
  1736. %       Optional: type, address, month, note
  1737.  
  1738. FUNCTION {mastersthesis}
  1739. { output.bibitem
  1740.   format.authors "author" output.check
  1741.   new.block
  1742.   format.title "title" output.check
  1743.   new.block
  1744.   "Master's thesis" format.thesis.type output.nonnull
  1745.   school "school" output.check
  1746.   address output
  1747.   format.date "year" output.check
  1748.   new.block
  1749.   note output
  1750.   fin.entry
  1751. }
  1752.  
  1753. % A misc is something that doesn't fit elsewhere.
  1754. %       Required: at least one of the `optional' fields
  1755. %       Optional: author, title, howpublished, month, year, note
  1756.  
  1757. FUNCTION {misc}
  1758. { output.bibitem
  1759.   format.authors output
  1760.   title howpublished new.block.checkb
  1761.   format.title output
  1762.   howpublished new.block.checka
  1763.   howpublished output
  1764.   format.date output
  1765. #if ISSN
  1766.   format.issn output
  1767. #endif
  1768. #if PRICE
  1769.   format.price output
  1770. #endif
  1771.   new.block
  1772.   note output
  1773.   fin.entry
  1774.   empty.misc.check
  1775. }
  1776.  
  1777. % A phdthesis is like a mastersthesis.
  1778. %       Required: author, title, school, year
  1779. %       Optional: type, address, month, note
  1780.  
  1781. FUNCTION {phdthesis}
  1782. { output.bibitem
  1783.   format.authors "author" output.check
  1784.   new.block
  1785.   format.btitle "title" output.check
  1786.   new.block
  1787.   "PhD thesis" format.thesis.type output.nonnull
  1788.   school "school" output.check
  1789.   address output
  1790.   format.date "year" output.check
  1791.   new.block
  1792.   note output
  1793.   fin.entry
  1794. }
  1795.  
  1796. % A periodical is a publication that appears at regular
  1797. % intervals.  This includes journals, magazines, and newspapers.
  1798. % If there is an organization but no editor field, the
  1799. % organization will appear as the first optional field (we try to
  1800. % make the first block nonempty); if there's no address field,
  1801. % the month (& year) will appear just before note.
  1802. %       Required: title, key
  1803. %       Optional: editor, volume, number, series, address, month, year,
  1804. %                       organization, publisher, note, issn,
  1805. %                       howpublished
  1806.  
  1807. FUNCTION {periodical}
  1808. { output.bibitem
  1809.   editor empty$
  1810.     { organization output }
  1811.     { format.editors output.nonnull }
  1812.   if$
  1813.   new.block
  1814.   title emphasize "title" output.check
  1815. %  format.bvolume output
  1816. %  format.number.series output
  1817.   format.vol.num.pages output
  1818.   format.date output
  1819. #if ISSN
  1820.   format.issn output
  1821. #endif
  1822. #if PRICE
  1823.   format.price output
  1824. #endif
  1825.   new.sentence
  1826.   publisher output
  1827.   address output
  1828.   howpublished new.block.checka
  1829.   howpublished output
  1830.   new.block
  1831.   note output
  1832.   fin.entry
  1833. }
  1834.  
  1835. % A proceedings is a conference proceedings.
  1836. % If there is an organization but no editor field, the organization will
  1837. % appear as the first optional field (we try to make the first block nonempty);
  1838. % if there's no address field, the month (& year) will appear just before note.
  1839. %       Required: title, year
  1840. %       Optional: editor, volume or number, series, address, month,
  1841. %                       organization, publisher, note
  1842.  
  1843. FUNCTION {proceedings}
  1844. { output.bibitem
  1845.   editor empty$
  1846.     { organization output }
  1847.     { format.editors output.nonnull }
  1848.   if$
  1849.   new.block
  1850.   format.btitle "title" output.check
  1851.   format.bvolume output
  1852.   format.number.series output
  1853.   address empty$
  1854.     { editor empty$
  1855.         { publisher new.sentence.checka }
  1856.         { organization publisher new.sentence.checkb
  1857.           organization output
  1858.         }
  1859.       if$
  1860.       publisher output
  1861.       format.date "year" output.check
  1862.     }
  1863.     { address output.nonnull
  1864.       format.date "year" output.check
  1865.       new.sentence
  1866.       editor empty$
  1867.         'skip$
  1868.         { organization output }
  1869.       if$
  1870.       publisher output
  1871.     }
  1872.   if$
  1873. #if ISBN
  1874.   format.isbn output
  1875. #endif
  1876. #if LCCN
  1877.   format.lccn output
  1878. #endif
  1879. #if PRICE
  1880.   format.price output
  1881. #endif
  1882.   new.block
  1883.   note output
  1884.   fin.entry
  1885. }
  1886.  
  1887. % A techreport is a technical report.
  1888. %       Required: author, title, institution, year
  1889. %       Optional: type, number, address, month, note
  1890.  
  1891. FUNCTION {techreport}
  1892. { output.bibitem
  1893.   format.authors "author" output.check
  1894.   new.block
  1895.   format.title "title" output.check
  1896.   new.block
  1897.   format.tr.number output.nonnull
  1898.   institution "institution" output.check
  1899.   address output
  1900.   format.date "year" output.check
  1901. #if PRICE
  1902.   format.price output
  1903. #endif
  1904.   new.block
  1905.   note output
  1906.   fin.entry
  1907. }
  1908.  
  1909. % An unpublished is something that hasn't been published.
  1910. %       Required: author, title, note
  1911. %       Optional: month, year
  1912.  
  1913. FUNCTION {unpublished}
  1914. { output.bibitem
  1915.   format.authors "author" output.check
  1916.   new.block
  1917.   format.title "title" output.check
  1918.   new.block
  1919.   note "note" output.check
  1920.   format.date output
  1921.   fin.entry
  1922. }
  1923.  
  1924. % We use entry type `misc' for an unknown type; BibTeX gives a warning.
  1925.  
  1926. FUNCTION {default.type} { misc }
  1927.  
  1928. % Here are macros for common things that may vary from style to style.
  1929. % Users are encouraged to use these macros.
  1930. %
  1931. % Months are either written out in full or abbreviated
  1932.  
  1933. #if MONTH_FULL
  1934.  
  1935. MACRO {jan} {"January"}
  1936.  
  1937. MACRO {feb} {"February"}
  1938.  
  1939. MACRO {mar} {"March"}
  1940.  
  1941. MACRO {apr} {"April"}
  1942.  
  1943. MACRO {may} {"May"}
  1944.  
  1945. MACRO {jun} {"June"}
  1946.  
  1947. MACRO {jul} {"July"}
  1948.  
  1949. MACRO {aug} {"August"}
  1950.  
  1951. MACRO {sep} {"September"}
  1952.  
  1953. MACRO {oct} {"October"}
  1954.  
  1955. MACRO {nov} {"November"}
  1956.  
  1957. MACRO {dec} {"December"}
  1958.  
  1959. #else !MONTH_FULL
  1960.  
  1961. MACRO {jan} {"Jan."}
  1962.  
  1963. MACRO {feb} {"Feb."}
  1964.  
  1965. MACRO {mar} {"Mar."}
  1966.  
  1967. MACRO {apr} {"Apr."}
  1968.  
  1969. MACRO {may} {"May"}
  1970.  
  1971. MACRO {jun} {"June"}
  1972.  
  1973. MACRO {jul} {"July"}
  1974.  
  1975. MACRO {aug} {"Aug."}
  1976.  
  1977. MACRO {sep} {"Sept."}
  1978.  
  1979. MACRO {oct} {"Oct."}
  1980.  
  1981. MACRO {nov} {"Nov."}
  1982.  
  1983. MACRO {dec} {"Dec."}
  1984.  
  1985. #endif MONTH_FULL
  1986.  
  1987. % Journals are either written out in full or abbreviated;
  1988. % the abbreviations are like those found in ACM publications.
  1989. %
  1990. % To get a completely different set of abbreviations, it may be best to make
  1991. % a separate .bib file with nothing but those abbreviations; users could then
  1992. % include that file name as the first argument to the \bibliography command
  1993.  
  1994. #if JOUR_FULL
  1995.  
  1996. MACRO {acmcs} {"ACM Computing Surveys"}
  1997.  
  1998. MACRO {acta} {"Acta Informatica"}
  1999.  
  2000. MACRO {cacm} {"Communications of the ACM"}
  2001.  
  2002. MACRO {ibmjrd} {"IBM Journal of Research and Development"}
  2003.  
  2004. MACRO {ibmsj} {"IBM Systems Journal"}
  2005.  
  2006. MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
  2007.  
  2008. MACRO {ieeetc} {"IEEE Transactions on Computers"}
  2009.  
  2010. MACRO {ieeetcad}
  2011.  {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
  2012.  
  2013. MACRO {ipl} {"Information Processing Letters"}
  2014.  
  2015. MACRO {jacm} {"Journal of the ACM"}
  2016.  
  2017. MACRO {jcss} {"Journal of Computer and System Sciences"}
  2018.  
  2019. MACRO {scp} {"Science of Computer Programming"}
  2020.  
  2021. MACRO {sicomp} {"SIAM Journal on Computing"}
  2022.  
  2023. MACRO {tocs} {"ACM Transactions on Computer Systems"}
  2024.  
  2025. MACRO {tods} {"ACM Transactions on Database Systems"}
  2026.  
  2027. MACRO {tog} {"ACM Transactions on Graphics"}
  2028.  
  2029. MACRO {toms} {"ACM Transactions on Mathematical Software"}
  2030.  
  2031. MACRO {toois} {"ACM Transactions on Office Information Systems"}
  2032.  
  2033. MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
  2034.  
  2035. MACRO {tcs} {"Theoretical Computer Science"}
  2036.  
  2037. #else !JOUR_FULL
  2038.  
  2039. MACRO {acmcs} {"ACM Comput. Surv."}
  2040.  
  2041. MACRO {acta} {"Acta Inf."}
  2042.  
  2043. MACRO {cacm} {"Commun. ACM"}
  2044.  
  2045. MACRO {ibmjrd} {"IBM J. Res. Dev."}
  2046.  
  2047. MACRO {ibmsj} {"IBM Syst.~J."}
  2048.  
  2049. MACRO {ieeese} {"IEEE Trans. Softw. Eng."}
  2050.  
  2051. MACRO {ieeetc} {"IEEE Trans. Comput."}
  2052.  
  2053. MACRO {ieeetcad}
  2054.  {"IEEE Trans. Comput.-Aided Design Integrated Circuits"}
  2055.  
  2056. MACRO {ipl} {"Inf. Process. Lett."}
  2057.  
  2058. MACRO {jacm} {"J.~ACM"}
  2059.  
  2060. MACRO {jcss} {"J.~Comput. Syst. Sci."}
  2061.  
  2062. MACRO {scp} {"Sci. Comput. Programming"}
  2063.  
  2064. MACRO {sicomp} {"SIAM J. Comput."}
  2065.  
  2066. MACRO {tocs} {"ACM Trans. Comput. Syst."}
  2067.  
  2068. MACRO {tods} {"ACM Trans. Database Syst."}
  2069.  
  2070. MACRO {tog} {"ACM Trans. Gr."}
  2071.  
  2072. MACRO {toms} {"ACM Trans. Math. Softw."}
  2073.  
  2074. MACRO {toois} {"ACM Trans. Office Inf. Syst."}
  2075.  
  2076. MACRO {toplas} {"ACM Trans. Prog. Lang. Syst."}
  2077.  
  2078. MACRO {tcs} {"Theoretical Comput. Sci."}
  2079.  
  2080. #endif JOUR_FULL
  2081.  
  2082. % Now we read in the .BIB entries.
  2083.  
  2084. READ
  2085.  
  2086. % The sortify function converts to lower case after purify$ing; it's
  2087. % used in sorting and in computing alphabetic labels after sorting
  2088. %
  2089. % The chop.word(w,len,s) function returns either s or, if the first len
  2090. % letters of s equals w (this comparison is done in the third line of the
  2091. % function's definition), it returns that part of s after w.
  2092.  
  2093. #if SORTED
  2094.  
  2095. FUNCTION {sortify}
  2096. { purify$
  2097.   "l" change.case$
  2098. }
  2099.  
  2100. INTEGERS { len }
  2101.  
  2102. FUNCTION {chop.word}
  2103. { 's :=
  2104.   'len :=
  2105.   s #1 len substring$ =
  2106.     { s len #1 + global.max$ substring$ }
  2107.     's
  2108.   if$
  2109. }
  2110.  
  2111. #else !SORTED
  2112. #if LAB_ALPH
  2113.  
  2114. % We need the chop.word stuff for the dubious unsorted-list-with-labels case.
  2115.  
  2116. INTEGERS { len }
  2117.  
  2118. FUNCTION {chop.word}
  2119. { 's :=
  2120.   'len :=
  2121.   s #1 len substring$ =
  2122.     { s len #1 + global.max$ substring$ }
  2123.     's
  2124.   if$
  2125. }
  2126.  
  2127. #endif LAB_ALPH
  2128. #endif SORTED
  2129.  
  2130. % This long comment applies only to alphabetic labels
  2131. %
  2132. % The format.lab.names function makes a short label by using the initials of
  2133. % the von and Last parts of the names (but if there are more than four names,
  2134. % (i.e., people) it truncates after three and adds a superscripted "+";
  2135. % it also adds such a "+" if the last of multiple authors is "others").
  2136. % If there is only one name, and its von and Last parts combined have just
  2137. % a single name-token ("Knuth" has a single token, "Brinch Hansen" has two),
  2138. % we take the first three letters of the last name.  The boolean
  2139. % et.al.char.used tells whether we've used a superscripted "+", so that we
  2140. % know whether to include a LaTeX macro for it.
  2141. %
  2142. % format.lab.names(s) ==
  2143. %  BEGIN
  2144. %       numnames := num.names$(s)
  2145. %       if numnames > 1 then
  2146. %           if numnames > 4 then
  2147. %               namesleft := 3
  2148. %           else
  2149. %               namesleft := numnames
  2150. %           nameptr := 1
  2151. %           nameresult := ""
  2152. %           while namesleft > 0
  2153. %             do
  2154. %               if (name_ptr = numnames) and
  2155. %                    format.name$(s, nameptr, "{ff }{vv }{ll}{ jj}") = "others"
  2156. %                  then nameresult := nameresult * "{\etalchar{+}}"
  2157. %                       et.al.char.used := true
  2158. %                  else nameresult := nameresult *
  2159. %                               format.name$(s, nameptr, "{v{}}{l{}}")
  2160. %               nameptr := nameptr + 1
  2161. %               namesleft := namesleft - 1
  2162. %             od
  2163. %           if numnames > 4 then
  2164. %               nameresult := nameresult * "{\etalchar{+}}"
  2165. %               et.al.char.used := true
  2166. %       else
  2167. %           t := format.name$(s, 1, "{v{}}{l{}}")
  2168. %           if text.length$(t) < 2 then % there's just one name-token
  2169. %               nameresult := text.prefix$(format.name$(s,1,"{ll}"),3)
  2170. %           else
  2171. %               nameresult := t
  2172. %           fi
  2173. %       fi
  2174. %       return nameresult
  2175. %  END
  2176. %
  2177. % Exactly what fields we look at in constructing the primary part of the label
  2178. % depends on the entry type; this selectivity (as opposed to, say, always
  2179. % looking at author, then editor, then key) helps ensure that "ignored" fields,
  2180. % as described in the LaTeX book, really are ignored.  Note that MISC is part
  2181. % of the deepest `else' clause in the nested part of calc.label; thus, any
  2182. % unrecognized entry type in the database is handled correctly.
  2183. %
  2184. % There is one auxiliary function for each of the four different sequences of
  2185. % fields we use.  The first of these functions looks at the author field, and
  2186. % then, if necessary, the key field.  The other three functions, which might
  2187. % look at two fields and the key field, are similar, except that the key field
  2188. % takes precedence over the organization field (for labels---not for sorting).
  2189. %
  2190. % The calc.label function calculates the preliminary label of an entry, which
  2191. % is formed by taking three letters of information from the author or editor or
  2192. % key or organization field (depending on the entry type and on what's empty,
  2193. % but ignoring a leading "The " in the organization), and appending the last
  2194. % two characters (digits) of the year. It is an error if the appropriate fields
  2195. % among author, editor, organization, and key are missing, and we use
  2196. % the first three letters of the cite$ in desperation when this happens.
  2197. % The resulting label has the year part, but not the name part, purify$ed
  2198. % (purify$ing the year allows some sorting shenanigans by the user).
  2199. %
  2200. % This function also calculates the version of the label to be used in sorting.
  2201. %
  2202. % The final label may need a trailing 'a', 'b', etc., to distinguish it from
  2203. % otherwise identical labels, but we can't calculated those "extra.label"s
  2204. % until after sorting.
  2205. %
  2206. % calc.label ==
  2207. %  BEGIN
  2208. %       if type$ = "book" or "inbook" then
  2209. %           author.editor.key.label
  2210. %       else if type$ = "proceedings" then
  2211. %           editor.key.organization.label
  2212. %       else if type$ = "manual" then
  2213. %           author.key.organization.label
  2214. %       else
  2215. %           author.key.label
  2216. %       fi fi fi
  2217. %       label := label * substring$(purify$(field.or.null(year)), -1, 2)
  2218. %               % assuming we will also sort, we calculate a sort.label
  2219. %       sort.label := sortify(label), but use the last four, not two, digits
  2220. %  END
  2221.  
  2222. #if LAB_ALPH
  2223.  
  2224. INTEGERS { et.al.char.used }
  2225.  
  2226. FUNCTION {initialize.et.al.char.used}
  2227. { #0 'et.al.char.used :=
  2228. }
  2229.  
  2230. EXECUTE {initialize.et.al.char.used}
  2231.  
  2232. FUNCTION {format.lab.names}
  2233. { 's :=
  2234.   s num.names$ 'numnames :=
  2235.   numnames #1 >
  2236.     { numnames #4 >
  2237.         { #3 'namesleft := }
  2238.         { numnames 'namesleft := }
  2239.       if$
  2240.       #1 'nameptr :=
  2241.       ""
  2242.         { namesleft #0 > }
  2243.         { nameptr numnames =
  2244.             { s nameptr "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  2245.                 { "{\etalchar{+}}" *
  2246.                   #1 'et.al.char.used :=
  2247.                 }
  2248.                 { s nameptr "{v{}}{l{}}" format.name$ * }
  2249.               if$
  2250.             }
  2251.             { s nameptr "{v{}}{l{}}" format.name$ * }
  2252.           if$
  2253.           nameptr #1 + 'nameptr :=
  2254.           namesleft #1 - 'namesleft :=
  2255.         }
  2256.       while$
  2257.       numnames #4 >
  2258.         { "{\etalchar{+}}" *
  2259.           #1 'et.al.char.used :=
  2260.         }
  2261.         'skip$
  2262.       if$
  2263.     }
  2264.     { s #1 "{v{}}{l{}}" format.name$
  2265.       duplicate$ text.length$ #2 <
  2266.         { pop$ s #1 "{ll}" format.name$ #3 text.prefix$ }
  2267.         'skip$
  2268.       if$
  2269.     }
  2270.   if$
  2271. }
  2272.  
  2273. FUNCTION {author.key.label}
  2274. { author empty$
  2275.     { key empty$
  2276. #if SORTED
  2277.         { cite$ #1 #3 substring$ }
  2278. #else !SORTED           % need warning here because we won't give it later
  2279.         { "for label, need author or key in " cite$ * warning$
  2280.           cite$ #1 #3 substring$
  2281.         }
  2282. #endif SORTED
  2283.         { key #3 text.prefix$ }
  2284.       if$
  2285.     }
  2286.     { author format.lab.names }
  2287.   if$
  2288. }
  2289.  
  2290. FUNCTION {author.editor.key.label}
  2291. { author empty$
  2292.     { editor empty$
  2293.         { key empty$
  2294. #if SORTED
  2295.             { cite$ #1 #3 substring$ }
  2296. #else !SORTED           % need warning here because we won't give it later
  2297.             { "for label, need author, editor, or key in " cite$ * warning$
  2298.               cite$ #1 #3 substring$
  2299.             }
  2300. #endif SORTED
  2301.             { key #3 text.prefix$ }
  2302.           if$
  2303.         }
  2304.         { editor format.lab.names }
  2305.       if$
  2306.     }
  2307.     { author format.lab.names }
  2308.   if$
  2309. }
  2310.  
  2311. FUNCTION {author.key.organization.label}
  2312. { author empty$
  2313.     { key empty$
  2314.         { organization empty$
  2315. #if SORTED
  2316.             { cite$ #1 #3 substring$ }
  2317. #else !SORTED           % need warning here because we won't give it later
  2318.             { "for label, need author, key, or organization in " cite$ *
  2319.                                                                 warning$
  2320.               cite$ #1 #3 substring$
  2321.             }
  2322. #endif SORTED
  2323.             { "The " #4 organization chop.word #3 text.prefix$ }
  2324.           if$
  2325.         }
  2326.         { key #3 text.prefix$ }
  2327.       if$
  2328.     }
  2329.     { author format.lab.names }
  2330.   if$
  2331. }
  2332.  
  2333. FUNCTION {editor.key.organization.label}
  2334. { editor empty$
  2335.     { key empty$
  2336.         { organization empty$
  2337. #if SORTED
  2338.             { cite$ #1 #3 substring$ }
  2339. #else !SORTED           % need warning here because we won't give it later
  2340.             { "for label, need editor, key, or organization in " cite$ *
  2341.                                                                 warning$
  2342.               cite$ #1 #3 substring$
  2343.             }
  2344. #endif SORTED
  2345.             { "The " #4 organization chop.word #3 text.prefix$ }
  2346.           if$
  2347.         }
  2348.         { key #3 text.prefix$ }
  2349.       if$
  2350.     }
  2351.     { editor format.lab.names }
  2352.   if$
  2353. }
  2354.  
  2355. FUNCTION {calc.label}
  2356. { type$ "book" =
  2357.   type$ "inbook" =
  2358.   or
  2359.     'author.editor.key.label
  2360.     { type$ "proceedings" =
  2361.         'editor.key.organization.label
  2362.         { type$ "manual" =
  2363.             'author.key.organization.label
  2364.             'author.key.label
  2365.           if$
  2366.         }
  2367.       if$
  2368.     }
  2369.   if$
  2370.   duplicate$
  2371.   year field.or.null purify$ #-1 #2 substring$
  2372.   *
  2373.   'label :=
  2374.   year field.or.null purify$ #-1 #4 substring$
  2375.   *
  2376.   sortify 'sort.label :=
  2377. }
  2378.  
  2379. % It doesn't seem like a particularly good idea to use an order-of-citation
  2380. % reference list when using alphabetic labels, but we need to have a
  2381. % special pass to calculate labels when this happens.
  2382.  
  2383. #if !SORTED
  2384.  
  2385. ITERATE {calc.label}
  2386.  
  2387. #endif !SORTED
  2388.  
  2389. #endif LAB_ALPH
  2390.  
  2391. % When sorting, we compute the sortkey by executing "presort" on each entry.
  2392. % The presort key contains a number of "sortify"ed strings, concatenated
  2393. % with multiple blanks between them.  This makes things like "brinch  per"
  2394. % come before "brinch hansen  per".
  2395. %
  2396. % The fields used here are: the sort.label for alphabetic labels (as set by
  2397. % calc.label), followed by the author names (or editor names or organization
  2398. % (with a leading "The " removed) or key field, depending on entry type and on
  2399. % what's empty), followed by year, followed by the first bit of the title
  2400. % (chopping off a leading "The ", "A ", or "An ").
  2401. % Names are formatted: Von Last First Junior.
  2402. % The names within a part will be separated by a single blank
  2403. % (such as "brinch hansen"), two will separate the name parts themselves
  2404. % (except the von and last), three will separate the names,
  2405. % four will separate the names from year (and from label, if alphabetic),
  2406. % and four will separate year from title.
  2407. %
  2408. % The sort.format.names function takes an argument that should be in
  2409. % BibTeX name format, and returns a string containing "   "-separated
  2410. % names in the format described above.  The function is almost the same
  2411. % as format.names.
  2412.  
  2413. #if SORTED
  2414.  
  2415. FUNCTION {sort.format.names}
  2416. { 's :=
  2417.   #1 'nameptr :=
  2418.   ""
  2419.   s num.names$ 'numnames :=
  2420.   numnames 'namesleft :=
  2421.     { namesleft #0 > }
  2422.     { nameptr #1 >
  2423.         { "   " * }
  2424.         'skip$
  2425.       if$
  2426. #if NAME_FULL
  2427.       s nameptr "{vv{ } }{ll{ }}{  ff{ }}{  jj{ }}" format.name$ 't :=
  2428. #else
  2429.       s nameptr "{vv{ } }{ll{ }}{  f{ }}{  jj{ }}" format.name$ 't :=
  2430. #endif NAME_FULL
  2431.       nameptr numnames = t "others" = and
  2432.         { "et al" * }
  2433.         { t sortify * }
  2434.       if$
  2435.       nameptr #1 + 'nameptr :=
  2436.       namesleft #1 - 'namesleft :=
  2437.     }
  2438.   while$
  2439. }
  2440.  
  2441. % The sort.format.title function returns the argument,
  2442. % but first any leading "A "'s, "An "'s, or "The "'s are removed.
  2443. % The chop.word function uses s, so we need another string variable, t
  2444.  
  2445. FUNCTION {sort.format.title}
  2446. { 't :=
  2447.   "A " #2
  2448.     "An " #3
  2449.       "The " #4 t chop.word
  2450.     chop.word
  2451.   chop.word
  2452.   sortify
  2453.   #1 global.max$ substring$
  2454. }
  2455.  
  2456. % The auxiliary functions here, for the presort function, are analogous to
  2457. % the ones for calc.label; the same comments apply, except that the
  2458. % organization field takes precedence here over the key field.  For sorting
  2459. % purposes, we still remove a leading "The " from the organization field.
  2460.  
  2461. FUNCTION {author.sort}
  2462. { author empty$
  2463.     { key empty$
  2464.         { "to sort, need author or key in " cite$ * warning$
  2465.           ""
  2466.         }
  2467.         { key sortify }
  2468.       if$
  2469.     }
  2470.     { author sort.format.names }
  2471.   if$
  2472. }
  2473.  
  2474. FUNCTION {author.editor.sort}
  2475. { author empty$
  2476.     { editor empty$
  2477.         { key empty$
  2478.             { "to sort, need author, editor, or key in " cite$ * warning$
  2479.               ""
  2480.             }
  2481.             { key sortify }
  2482.           if$
  2483.         }
  2484.         { editor sort.format.names }
  2485.       if$
  2486.     }
  2487.     { author sort.format.names }
  2488.   if$
  2489. }
  2490.  
  2491. FUNCTION {author.organization.sort}
  2492. { author empty$
  2493.     { organization empty$
  2494.         { key empty$
  2495.             { "to sort, need author, organization, or key in " cite$ * warning$
  2496.               ""
  2497.             }
  2498.             { key sortify }
  2499.           if$
  2500.         }
  2501.         { "The " #4 organization chop.word sortify }
  2502.       if$
  2503.     }
  2504.     { author sort.format.names }
  2505.   if$
  2506. }
  2507.  
  2508. FUNCTION {editor.organization.sort}
  2509. { editor empty$
  2510.     { organization empty$
  2511.         { key empty$
  2512.             { "to sort, need editor, organization, or key in " cite$ * warning$
  2513.               ""
  2514.             }
  2515.             { key sortify }
  2516.           if$
  2517.         }
  2518.         { "The " #4 organization chop.word sortify }
  2519.       if$
  2520.     }
  2521.     { editor sort.format.names }
  2522.   if$
  2523. }
  2524.  
  2525. % There is a limit, entry.max$, on the length of an entry string variable
  2526. % (which is what its sort.key$ is), so we take at most that many characters
  2527. % of the constructed key, and hope there aren't many references that match
  2528. % to that many characters!
  2529.  
  2530. FUNCTION {presort}
  2531. #if LAB_ALPH
  2532. { calc.label
  2533.   sort.label
  2534.   "    "
  2535.   *
  2536.   type$ "book" =
  2537. #else !LAB_ALPH
  2538. { type$ "book" =
  2539. #endif LAB_ALPH
  2540.   type$ "inbook" =
  2541.   or
  2542.     'author.editor.sort
  2543.     { type$ "proceedings" =
  2544.         'editor.organization.sort
  2545.         { type$ "manual" =
  2546.             'author.organization.sort
  2547.             'author.sort
  2548.           if$
  2549.         }
  2550.       if$
  2551.     }
  2552.   if$
  2553. #if LAB_ALPH
  2554.   *
  2555. #endif LAB_ALPH
  2556.   "    "
  2557.   *
  2558.   year field.or.null sortify
  2559.   *
  2560.   "    "
  2561.   *
  2562.   title field.or.null
  2563.   sort.format.title
  2564.   *
  2565.   #1 entry.max$ substring$
  2566.   'sort.key$ :=
  2567. }
  2568.  
  2569. ITERATE {presort}
  2570.  
  2571. % And now we can sort
  2572.  
  2573. SORT
  2574.  
  2575. #endif SORTED
  2576.  
  2577. % This long comment applies only to alphabetic labels, when sorted
  2578. %
  2579. % Now comes the final computation for alphabetic labels, putting in the 'a's
  2580. % and 'b's and so forth if required.  This involves two passes: a forward
  2581. % pass to put in the 'b's, 'c's and so on, and a backwards pass
  2582. % to put in the 'a's (we don't want to put in 'a's unless we know there
  2583. % are 'b's).
  2584. % We have to keep track of the longest (in width$ terms) label, for use
  2585. % by the "thebibliography" environment.
  2586. %
  2587. % VAR: longest.label, last.sort.label, next.extra: string
  2588. %      longest.label.width, last.extra.num: integer
  2589. %
  2590. % initialize.longest.label ==
  2591. %  BEGIN
  2592. %       longest.label := ""
  2593. %       last.sort.label := int.to.chr$(0)
  2594. %       next.extra := ""
  2595. %       longest.label.width := 0
  2596. %       last.extra.num := 0
  2597. %  END
  2598. %
  2599. % forward.pass ==
  2600. %  BEGIN
  2601. %       if last.sort.label = sort.label then
  2602. %           last.extra.num := last.extra.num + 1
  2603. %           extra.label := int.to.chr$(last.extra.num)
  2604. %       else
  2605. %           last.extra.num := chr.to.int$("a")
  2606. %           extra.label := ""
  2607. %           last.sort.label := sort.label
  2608. %       fi
  2609. %  END
  2610. %
  2611. % reverse.pass ==
  2612. %  BEGIN
  2613. %       if next.extra = "b" then
  2614. %           extra.label := "a"
  2615. %       fi
  2616. %       label := label * extra.label
  2617. %       if width$(label) > longest.label.width then
  2618. %           longest.label := label
  2619. %           longest.label.width := width$(label)
  2620. %       fi
  2621. %       next.extra := extra.label
  2622. %  END
  2623.  
  2624. #if LAB_ALPH
  2625.  
  2626. #if SORTED
  2627.  
  2628. STRINGS { longest.label last.sort.label next.extra }
  2629.  
  2630. INTEGERS { longest.label.width last.extra.num }
  2631.  
  2632. FUNCTION {initialize.longest.label}
  2633. { "" 'longest.label :=
  2634.   #0 int.to.chr$ 'last.sort.label :=
  2635.   "" 'next.extra :=
  2636.   #0 'longest.label.width :=
  2637.   #0 'last.extra.num :=
  2638. }
  2639.  
  2640. FUNCTION {forward.pass}
  2641. { last.sort.label sort.label =
  2642.     { last.extra.num #1 + 'last.extra.num :=
  2643.       last.extra.num int.to.chr$ 'extra.label :=
  2644.     }
  2645.     { "a" chr.to.int$ 'last.extra.num :=
  2646.       "" 'extra.label :=
  2647.       sort.label 'last.sort.label :=
  2648.     }
  2649.   if$
  2650. }
  2651.  
  2652. FUNCTION {reverse.pass}
  2653. { next.extra "b" =
  2654.     { "a" 'extra.label := }
  2655.     'skip$
  2656.   if$
  2657.   label extra.label * 'label :=
  2658.   label width$ longest.label.width >
  2659.     { label 'longest.label :=
  2660.       label width$ 'longest.label.width :=
  2661.     }
  2662.     'skip$
  2663.   if$
  2664.   extra.label 'next.extra :=
  2665. }
  2666.  
  2667. EXECUTE {initialize.longest.label}
  2668.  
  2669. ITERATE {forward.pass}
  2670.  
  2671. REVERSE {reverse.pass}
  2672.  
  2673. #else !SORTED
  2674.  
  2675. % It still doesn't seem like a good idea to use an order-of-citation
  2676. % reference list when using alphabetic labels, but when this happens we
  2677. % must compute the longest label
  2678.  
  2679. STRINGS { longest.label }
  2680.  
  2681. INTEGERS { longest.label.width }
  2682.  
  2683. FUNCTION {initialize.longest.label}
  2684. { "" 'longest.label :=
  2685.   #0 'longest.label.width :=
  2686. }
  2687.  
  2688. FUNCTION {longest.label.pass}
  2689. { label width$ longest.label.width >
  2690.     { label 'longest.label :=
  2691.       label width$ 'longest.label.width :=
  2692.     }
  2693.     'skip$
  2694.   if$
  2695. }
  2696.  
  2697. EXECUTE {initialize.longest.label}
  2698.  
  2699. ITERATE {longest.label.pass}
  2700.  
  2701. #endif SORTED
  2702.  
  2703. #else !LAB_ALPH
  2704.  
  2705. % Now comes the computation for numeric labels.
  2706. % We use either the sorted order or original order.
  2707. % We still have to keep track of the longest (in width$ terms) label, for use
  2708. % by the "thebibliography" environment.
  2709.  
  2710. STRINGS { longest.label }
  2711.  
  2712. INTEGERS { number.label longest.label.width }
  2713.  
  2714. FUNCTION {initialize.longest.label}
  2715. { "" 'longest.label :=
  2716.   #1 'number.label :=
  2717.   #0 'longest.label.width :=
  2718. }
  2719.  
  2720. FUNCTION {longest.label.pass}
  2721. { number.label int.to.str$ 'label :=
  2722.   number.label #1 + 'number.label :=
  2723.   label width$ longest.label.width >
  2724.     { label 'longest.label :=
  2725.       label width$ 'longest.label.width :=
  2726.     }
  2727.     'skip$
  2728.   if$
  2729. }
  2730.  
  2731. EXECUTE {initialize.longest.label}
  2732.  
  2733. ITERATE {longest.label.pass}
  2734.  
  2735. #endif LAB_ALPH
  2736.  
  2737. % Now we're ready to start writing the .BBL file.
  2738. % We begin, if necessary, with a LaTeX macro for unnamed names in an alphabetic
  2739. % label; next comes stuff from the `preamble' command in the database files.
  2740. % Then we give an incantation containing the command
  2741. %     \begin{thebibliography}{...}
  2742. % where the `...' is the longest label.
  2743. %
  2744. % We also call init.state.consts, for use by the output routines.
  2745.  
  2746. FUNCTION {begin.bib}
  2747. #if LAB_ALPH
  2748. { et.al.char.used
  2749.     { "\newcommand{\etalchar}[1]{$^{#1}$}" write$ newline$ }
  2750.     'skip$
  2751.   if$
  2752.   preamble$ empty$
  2753. #else !LAB_ALPH
  2754. { preamble$ empty$
  2755. #endif LAB_ALPH
  2756.     'skip$
  2757.     { preamble$ write$ newline$ }
  2758.   if$
  2759.   "\begin{thebibliography}{"  longest.label  * "}" * write$ newline$
  2760. }
  2761.  
  2762. EXECUTE {begin.bib}
  2763.  
  2764. EXECUTE {init.state.consts}
  2765.  
  2766. % Now we produce the output for all the entries
  2767.  
  2768. ITERATE {call.type$}
  2769.  
  2770. % Finally, we finish up by writing the `\end{thebibliography}' command.
  2771.  
  2772. FUNCTION {end.bib}
  2773. { newline$
  2774.   "\end{thebibliography}" write$ newline$
  2775. }
  2776.  
  2777. EXECUTE {end.bib}
  2778.